<!DOCTYPE html>
<html>
<head>
    <title>累加求和</title>
</head>
<body>
    <input type="text" id="inputNum">
    <button onclick="sum()">计算累加和</button>
    <p id="sumResult"></p>

    <script>
        function sum() {
            const input = document.getElementById('inputNum').value;
            const num = parseInt(input);
            
            if(!isNaN(num) && num > 0) {
                const total = num * (num + 1) / 2;
                document.getElementById('sumResult').innerText = `累加和: ${total}`;
            } else {
                document.getElementById('sumResult').innerText = "请输入有效正整数";
            }
        }
    </script>
</body>
</html>